home *** CD-ROM | disk | FTP | other *** search
-
- PEEKs, POKEs, and SYSes -- Part 18
-
-
- by Jimmy Weiler
-
-
-
-
- Next, we have to tell VIC that the
-
- sprite we have defined can be found
-
- at memory location 832. At the same
-
- time, we will tell VIC that it is
-
- sprite number zero.
-
-
- As far as VIC is concerned, memory
-
- is divided into 64-byte pages, each
-
- one capable of holding one sprite.
-
- Memory location zero is sprite page
-
- 0, 64 is sprite page 1, 128 is sprite
-
- page 3, etc. Our umbrella sprite is
-
- at memory location 832 which is sprite
-
- page 13 (832/64 = 13).
-
-
- VIC can keep track of eight sprites
-
- at a time. The sprites are numbered
-
- 0 to 7. Memory locations 2040 to 2047
-
- tell VIC where, in terms of sprite
-
- pages, each of the eight sprite image
-
- blocks is located in memory. To tell
-
- VIC that sprite 0 is located in memory
-
- at address 832, you POKE 2040,13.
-
-
- 120 POKE 2040,13
-
-
- Now VIC knows where to find the
-
- sprite image, but doesn't know where
-
- to DRAW it. VIC finds out where we
-
- want our sprites drawn by checking
-
- memory locations 53248 to 53264.
-
- (That's V + 0 to V + 16, for those of
-
- you following that convention I told
-
- you about earlier.)
-
- V+ 0 sprite 0 horizontal position
- V+ 1 sprite 0 vertical position
- V+ 2 sprite 1 horizontal position
- V+ 3 sprite 1 vertical position
- V+ 4 sprite 2 horizontal position
- V+ 5 sprite 2 vertical position
- V+ 6 sprite 3 horizontal position
- V+ 7 sprite 3 vertical position
- V+ 8 sprite 4 horizontal position
- V+ 9 sprite 4 vertical position
- V+10 sprite 5 horizontal position
- V+11 sprite 5 vertical position
- V+12 sprite 6 horizontal position
- V+13 sprite 6 vertical position
- V+14 sprite 7 horizontal position
- V+15 sprite 7 vertical position
- V+16 sprite 0-7 horizontal hi-byte
-
-
- Let's just talk about the positon of
-
- sprite 0. We'll put it at the top of
-
- the screen, about in the middle.
-
-
- 130 V = 53248
- 140 POKE V+0,180
- 150 POKE V+1,50
- 160 POKE V+16,PEEK(V+16)AND254
-
-
- Line 160 makes sure that our sprite
-
- appears in the middle of the screen
-
- and not somewhere off to the right
-
- where we couldn't see it. Each bit
-
- set in V+16 tells VIC to add 256 to
-
- the horizontal position of the sprite
-
- corresponding to that bit. We AND
-
- that location with 254 to prevent any
-
- change in the horizontal positions of
-
- the other seven sprites (#1-7, which
-
- are represented by bits 1-7).
-
-
- Note well that sprites can be placed
-
- off the edge of the visible screen.
-
- The viewing area is from vertical
-
- position 50 to vertical position 250,
-
- and from horizontal 24 to horizontal
-
- 256+65.
-
- -------- Continued in Part 19 --------
-